home *** CD-ROM | disk | FTP | other *** search
- void add_hit(int x, int y);
- void stop_bullet(int a);
- /**--------------------------------------------------------------
- **
- **--------------------------------------------------------------
- ** MODULE : bullet.c
- ** PURPOSE : <t> bullet manager for interpreter
- ** PROGRAMMER : Sandy
- ** START DATE : 11/29/1988 11:55:11
- ** DESCRIPTION:
- ** :
- ** :
- **==============================================================
- **/
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <dos.h>
- #include <conio.h>
- #include <string.h>
-
- #include "dtypes.h"
- #include "host.h"
- #include "newload.h"
- #include "bullet.h"
- #include "callasm.h"
-
- #include "tiles.h"
-
- extern BOOL update_scr;
-
- #define TANKSTART TANK1D8A
- #define isbullet(x) (((x)>=CANNONBL && (x)<TANKSTART) ? TRUE : FALSE)
-
- int nhits;
- int nshots;
- BULLET shots[50];
- HITS hits[50];
- int setbullet;
-
- /*<f>----------------------------------------
- * FUNCTION: <s> void init_bullet(int x, int y, int xi, int yi, int r)
- * PURPOSE : Initilize a bullet to start at (x,y) and increment at
- * : (xi,yi) with a range of r units
- * CREATION: 12/05/1988 19:01:53
- */
- void init_bullet(int x, int y, int xi, int yi, int r)
- {
- if (nshots>48) return;
-
- shots[nshots].bx=x;
- shots[nshots].by=y;
- shots[nshots].obx=x+xi;
- shots[nshots].oby=y+yi;
- shots[nshots].incx=xi;
- shots[nshots].incy=yi;
- shots[nshots].range=r;
- shots[nshots].dead=FALSE;
- shots[nshots].misstile=setbullet;
- shots[nshots].saveunder=getmapXY(shots[nshots].obx,shots[nshots].oby);
- if (isbullet(shots[nshots].saveunder))
- shots[nshots].saveunder=NOTILE;
-
- nshots++;
-
- } /* void init_bullet(int x, int y, int xi, int yi, int r) */
-
- /*<f>----------------------------------------
- * FUNCTION: <s> void init_bullets(void)
- * PURPOSE : Initilize bullet manager
- * :
- * CREATION: 12/05/1988 19:02:42
- */
- void init_bullets(void)
- {
- nshots=0;
- } /* void init_bullets(void) */
-
- /*<f>----------------------------------------
- * FUNCTION: <s> void move_bullets(void)
- * PURPOSE : Move bullets around the screen
- * :
- * CREATION: 12/05/1988 19:03:06
- */
- void move_bullets(void)
- {
- int a, keep;
-
- nhits=0;
-
- for (a=0; a<nshots; a++)
- if (!shots[a].dead) {
-
- update_scr=TRUE;
-
- shots[a].bx+=shots[a].incx;
- shots[a].by+=shots[a].incy;
- shots[a].range--;
-
- if (shots[a].bx<=MINPX ||
- shots[a].bx>=MAXPX ||
- shots[a].by<=MINPY ||
- shots[a].by>=MAXPY ||
- shots[a].range<1
- ) {
- setmapXY(shots[a].obx,shots[a].oby,shots[a].saveunder);
- stop_bullet(a);
- a--;
- } else {
- keep=getmapXY(shots[a].bx,shots[a].by);
- if (isbullet(keep)) keep=NOTILE;
-
- setmapXY(shots[a].bx,shots[a].by,shots[a].misstile);
- setmapXY(shots[a].obx,shots[a].oby,shots[a].saveunder);
-
- shots[a].saveunder=keep;
- shots[a].obx=shots[a].bx;
- shots[a].oby=shots[a].by;
-
- if (keep>=TANKSTART || (keep>=BRICK && keep<TANK1D8A) || keep==TRED) { /* Hit */
- if (keep<TANKSTART)
- setmapXY(shots[a].bx,shots[a].by,shots[a].saveunder);
- add_hit(shots[a].bx,shots[a].by);
- stop_bullet(a);
- a--;
- }
- }
- }
- } /* void move_bullets(void) */
-
- /*<f>----------------------------------------
- * FUNCTION: <s> void stop_bullet(int a)
- * PURPOSE : Stop bullet A
- * :
- * CREATION: 12/06/1988 07:42:03
- */
- void stop_bullet(int a)
- {
- if (a<nshots-1)
- memcpy(&shots[a],&shots[nshots-1],sizeof(BULLET));
- nshots--;
- } /* void stop_bullet(int a) */
-
- /*<f>----------------------------------------
- * FUNCTION: <s> void add_hit(int x, int y)
- * PURPOSE : Add a registered hit to list
- * :
- * CREATION: 01/10/1989 13:55:18
- */
- void add_hit(int x, int y)
- {
- hits[nhits].hx =x;
- hits[nhits++].hy=y;
- } /* void add_hit(int x, int y) */